<html layout:decorator="/layout/main" xmlns:miguo="http://www.w3.org/1999/html">
<div layout:fragment="content">
    <link rel="stylesheet" th:href="@{/assets/module/steps/steps.css}"/>
    <link rel="stylesheet" th:href="@{/assets/module/tagsInput/tagsInput.css}"/>
    <script type="text/javascript" th:src="@{/assets/module/tagsInput/tagsInput.js}"></script>

    <div class="layui-tab layui-steps layui-steps-readonly" lay-filter="formStepsStep" style="min-width: 750px;">
        <!-- 标题 -->
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="steps-0">
                <i class="layui-icon layui-icon-ok">1</i>
                <span class="layui-steps-title">第一步</span>
                <span class="layui-steps-content">填写商品信息</span>
            </li>
            <li lay-id="steps-1" class="">
                <i class="layui-icon layui-icon-ok">2</i>
                <span class="layui-steps-title">第二步</span>
                <span class="layui-steps-content">填写商品促销</span>
            </li>
            <li lay-id="steps-2" class="">
                <i class="layui-icon layui-icon-ok">3</i>
                <span class="layui-steps-title">第三步</span>
                <span class="layui-steps-content">填写商品属性</span>
            </li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <!-- 填写商品信息 -->
                <form class="layui-form model-form" style="min-width: 750px;margin: 0 auto;padding: 40px 30px 0 0;">
                    <input name="id" type="hidden" value="0">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品封面：</label>
                        <div class="layui-input-block"><div class="layui-upload-drag"><a href="javascript:void(0);"><img id="cover_show_id" src="/assets/images/default_upload.png" alt="上传图片" width="90" height="90"></a><input type="hidden" id="cover" name="cover" value=""></div><div style="margin-top:10px;"><button type="button" class="layui-btn" id="btnUploadImg_cover"><i class="layui-icon"></i>上传封面</button><input class="layui-upload-file" type="file" accept="image/*" name="file"></div><div class="layui-form-mid layui-word-aux">建议尺寸：建议上传尺寸450x450</div></div><style type="text/css">.layui-upload-drag {
                        position: relative;
                        padding: 10px;
                        border: 1px dashed #e2e2e2;
                        background-color: #fff;
                        text-align: center;
                        cursor: pointer;
                        color: #999;
                    }</style><script th:inline="javascript" type="text/javascript">layui.use(['upload','croppers'],function(){
                        //声明变量
                        var layer = layui.layer
                            ,upload = layui.upload
                            ,croppers = layui.croppers
                            ,$ = layui.$;

                        if(false) {

                            //图片裁剪组件
                            croppers.render({
                                elem: '#btnUploadImg_cover'
                                ,name:"cover"
                                ,saveW:450     //保存宽度
                                ,saveH:450
                                ,mark:1.0/1    //选取比例
                                ,area:['750px','500px']  //弹窗宽度
                                ,url: "/upload/uploadImage?name=product"
                                ,done: function(url){
                                    //上传完毕回调
                                    $('#cover').val(url);
                                    $('#cover_show_id').attr('src',url);
                                }
                            });

                        }else{

                            /**
                             * 普通图片上传
                             */
                            var uploadInst = upload.render({
                                elem: '#btnUploadImg_cover'
                                ,url: "/upload/uploadImage?name=product"
                                ,accept:'images'
                                ,acceptMime:'image/*'
                                ,exts: "jpg|png|gif|bmp|jpeg"
                                ,field:'file'//文件域字段名
                                ,size: 1024 * 10 //最大允许上传的文件大小
                                ,before: function(obj){
                                    //预读本地文件
                                }
                                ,done: function(res){
                                    //上传完毕回调

                                    if(res.code!=0){
                                        layer.msg(res.msg,{ icon: 5 });
                                        return false;
                                    }

                                    //上传成功
                                    $('#cover_show_id').attr('src', res.data);
                                    $('#cover').val(res.data);
                                }
                                ,error: function(){
                                    //请求异常回调
                                    return layer.msg('数据请求异常');
                                }
                            });

                        }

                    });</script>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">商品分类：</label>
                            <div class="layui-input-inline">
                                <select name="productCategoryId" id="productCategoryId" lay-verify="" lay-search="" lay-filter="productCategoryId"><option value="">【请选择商品分类】</option><option value="1">家用电器</option><option value="2">|-- 电视</option><option value="3">|-- 空调</option><option value="4">|-- 洗衣机</option><option value="8">男装</option><option value="9">|-- 男士休闲</option><option value="5">手机</option><option value="6">电脑</option><option value="7">家居</option></select><div class="layui-form-select"><div class="layui-select-title"><input type="text" placeholder="【请选择商品分类】" value="" class="layui-input"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit"><dd lay-value="" class="layui-select-tips">【请选择商品分类】</dd><dd lay-value="1" class="">家用电器</dd><dd lay-value="2" class="">|-- 电视</dd><dd lay-value="3" class="">|-- 空调</dd><dd lay-value="4" class="">|-- 洗衣机</dd><dd lay-value="8" class="">男装</dd><dd lay-value="9" class="">|-- 男士休闲</dd><dd lay-value="5" class="">手机</dd><dd lay-value="6" class="">电脑</dd><dd lay-value="7" class="">家居</dd></dl></div>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">商品标题：</label>
                            <div class="layui-input-inline">
                                <input name="productTitle" value="" lay-verify="required" autocomplete="off" placeholder="请输入商品标题" class="layui-input layui-form-danger" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">副标题：</label>
                            <div class="layui-input-inline">
                                <input name="productSubTitle" value="" lay-verify="required" autocomplete="off" placeholder="请输入商品副标题" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">商品品牌：</label>
                            <div class="layui-input-inline">
                                <select name="brandId" id="brandId" lay-verify="required" lay-search="" lay-filter="brandId"><option value="">【请选择商品品牌】</option><option value="1">美特斯邦威</option></select><div class="layui-form-select"><div class="layui-select-title"><input type="text" placeholder="【请选择商品品牌】" value="" class="layui-input"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit"><dd lay-value="" class="layui-select-tips">【请选择商品品牌】</dd><dd lay-value="1" class="">美特斯邦威</dd></dl></div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">商品标签：</label>
                            <div class="layui-input-inline">
                                <div id="productTags" style="max-width: 400px;"><xm-select ua="win" size="medium" tabindex="1"><input class="xm-select-default" lay-verify="required" lay-vertype="" name="productTags"><i class="xm-icon"></i><div class="xm-tips">商品标签</div><div class="xm-label single-row"><div class="scroll"><div class="label-content" title=""></div></div></div><div class="xm-body  absolute dis"><div tabindex="1" style="outline: none;"><div><div class="xm-toolbar"><div class="toolbar-tag"><i class="xm-iconfont xm-icon-quanxuan"></i><span>全选</span></div><div class="toolbar-tag"><i class="xm-iconfont xm-icon-qingkong"></i><span>清空</span></div></div><div class="xm-search"><i class="xm-iconfont xm-icon-sousuo"></i><input class="xm-input xm-search-input" placeholder="商品标签"></div><div class="scroll-body" style="max-height: 300px;"><div class="xm-option   show-icon"><i class="xm-option-icon xm-iconfont xm-icon-duox" style="border-color: rgb(0, 150, 136);"></i><div class="xm-option-content">今日新品</div></div><div class="xm-option   show-icon"><i class="xm-option-icon xm-iconfont xm-icon-duox" style="border-color: rgb(0, 150, 136);"></i><div class="xm-option-content">今日推荐</div></div></div></div></div></div></xm-select></div><script type="text/javascript">layui.use(['xmSelect'], function () {
                                var xmSelect = layui.xmSelect;
                                // 渲染多选下拉
                                xmSelect.render({
                                    el: '#productTags',
                                    name: 'productTags',
                                    layVerify: 'required',
                                    tips: '商品标签',
                                    empty: '呀, 没有数据呢',
                                    toolbar: {show: true},
                                    filterable: true,
                                    searchTips: '商品标签',
                                    radio: false,
                                    clickClose: false,
                                    max: '5',
                                    maxMethod(seles, item){
                                        alert(`${item.name}不能选了, 已经超了`)
                                    },            height: '300px',
                                    data: [{"":"0","name":"今日新品","value":1},{"":"0","name":"今日推荐","value":2}]        });	});</script>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">商品编号：</label>
                            <div class="layui-input-inline">
                                <input name="productSn" value="" lay-verify="required" autocomplete="off" placeholder="请输入商品编号" class="layui-input" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 625px;">
                        <label class="layui-form-label">商品简介：</label>
                        <div class="layui-input-block">
                            <textarea name="productInfo" placeholder="请输入商品简介" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">商品售价：</label>
                            <div class="layui-input-inline">
                                <input name="price" value="" lay-verify="required" autocomplete="off" placeholder="请输入商品售价（单位 元）" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">成本价：</label>
                            <div class="layui-input-inline">
                                <input name="costPrice" value="" lay-verify="required" autocomplete="off" placeholder="请输入成本价(单位 元)" class="layui-input" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">商品原价：</label>
                            <div class="layui-input-inline">
                                <input name="originalPrice" value="" lay-verify="required" autocomplete="off" placeholder="请输入商品原价（单位 元）" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">库存：</label>
                            <div class="layui-input-inline">
                                <input name="stock" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入stock" class="layui-input" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">库存预警：</label>
                            <div class="layui-input-inline">
                                <input name="lowStock" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入库存预警值" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">计量单位：</label>
                            <div class="layui-input-inline">
                                <input name="unit" value="" lay-verify="required" autocomplete="off" placeholder="请输入计量单位" class="layui-input" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">体积(m³)：</label>
                            <div class="layui-input-inline">
                                <input name="volume" value="" lay-verify="required" autocomplete="off" placeholder="请输入体积(m³)" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">重量(KG)：</label>
                            <div class="layui-input-inline">
                                <input name="weight" value="" lay-verify="required" autocomplete="off" placeholder="请输入重量(KG)" class="layui-input" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否包邮：</label>
                        <div class="layui-input-inline">
                            <input name="isPostage" id="isPostage" th:value="1" lay-skin="switch" lay-filter="isPostage" lay-text="包邮|不包邮" type="hidden" checked="" value="1"><div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch"><em>包邮</em><i></i></div><script th:inline="javascript" type="text/javascript">layui.use(['form'], function(){
                            var form = layui.form,
                                $ = layui.$;

                            if (1 == 1) {
                                $("#isPostage").attr('type', 'hidden').val(1);
                            } else {
                                $("#isPostage").attr('type', 'hidden').val(2);
                            }
                            form.on('switch(isPostage)', function(data) {
                                console.log('switch开关选择状态：'+this.checked);
                                $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
                            });
                        });</script>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">邮费：</label>
                            <div class="layui-input-inline">
                                <input name="postage" value="" lay-verify="required" autocomplete="off" placeholder="请输入邮费(单位 元)" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">运费模板：</label>
                            <div class="layui-input-inline">
                                <select name="feightTemplateId" id="feightTemplateId" lay-verify="required" lay-search="" lay-filter="feightTemplateId"><option value="">【请选择运费模板】</option><option value="1">江浙沪快件</option></select><div class="layui-form-select"><div class="layui-select-title"><input type="text" placeholder="【请选择运费模板】" value="" class="layui-input"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit"><dd lay-value="" class="layui-select-tips">【请选择运费模板】</dd><dd lay-value="1" class="">江浙沪快件</dd></dl></div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序：</label>
                        <div class="layui-input-inline">
                            <input name="sort" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入排序号" class="layui-input" type="text">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-filter="productInfoSubmit" lay-submit=""> 下一步，填写商品促销</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item layui-show">
                <!-- 填写促销信息 -->
                <form class="layui-form model-form" style="min-width: 750px;margin: 0 auto;padding: 40px 30px 0 0;">
                    <input name="id" type="hidden" value="0">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">赠送积分：</label>
                            <div class="layui-input-inline">
                                <input name="giftIntegral" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入赠送的积分" class="layui-input layui-form-danger" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">赠成长值：</label>
                            <div class="layui-input-inline">
                                <input name="giftGrowth" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入赠送的成长值" class="layui-input" type="text">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">限制积分：</label>
                            <div class="layui-input-inline">
                                <input name="useIntegralLimit" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入限制使用的积分数" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">审核状态：</label>
                            <div class="layui-input-inline">
                                <select name="verifyStatus" id="verifyStatus" lay-verify="required" lay-search="" lay-filter="verifyStatus"><option value="">【请选择审核状态】</option><option value="1">已审核</option><option value="2" selected="">待审核</option></select><div class="layui-form-select"><div class="layui-select-title"><input type="text" placeholder="【请选择审核状态】" value="待审核" class="layui-input"><i class="layui-edge"></i></div><dl class="layui-anim layui-anim-upbit"><dd lay-value="" class="layui-select-tips">【请选择审核状态】</dd><dd lay-value="1" class="">已审核</dd><dd lay-value="2" class="layui-this">待审核</dd></dl></div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">销量：</label>
                            <div class="layui-input-inline">
                                <input name="sales" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入销量" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">是否推荐：</label>
                            <div class="layui-input-inline">
                                <input name="isRecommand" id="isRecommand" th:value="2" lay-skin="switch" lay-filter="isRecommand" lay-text="是|否" type="hidden" value="2"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>否</em><i></i></div><script th:inline="javascript" type="text/javascript">layui.use(['form'], function(){
                                var form = layui.form,
                                    $ = layui.$;

                                if (2 == 1) {
                                    $("#isRecommand").attr('type', 'hidden').val(1);
                                } else {
                                    $("#isRecommand").attr('type', 'hidden').val(2);
                                }
                                form.on('switch(isRecommand)', function(data) {
                                    console.log('switch开关选择状态：'+this.checked);
                                    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
                                });
                            });</script>
                            </div>
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">是否新品：</label>
                            <div class="layui-input-inline">
                                <input name="isNew" id="isNew" th:value="2" lay-skin="switch" lay-filter="isNew" lay-text="是|否" type="hidden" value="2"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>否</em><i></i></div><script th:inline="javascript" type="text/javascript">layui.use(['form'], function(){
                                var form = layui.form,
                                    $ = layui.$;

                                if (2 == 1) {
                                    $("#isNew").attr('type', 'hidden').val(1);
                                } else {
                                    $("#isNew").attr('type', 'hidden').val(2);
                                }
                                form.on('switch(isNew)', function(data) {
                                    console.log('switch开关选择状态：'+this.checked);
                                    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
                                });
                            });</script>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">是否热卖：</label>
                            <div class="layui-input-inline">
                                <input name="isHot" id="isHot" th:value="2" lay-skin="switch" lay-filter="isHot" lay-text="是|否" type="hidden" value="2"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>否</em><i></i></div><script th:inline="javascript" type="text/javascript">layui.use(['form'], function(){
                                var form = layui.form,
                                    $ = layui.$;

                                if (2 == 1) {
                                    $("#isHot").attr('type', 'hidden').val(1);
                                } else {
                                    $("#isHot").attr('type', 'hidden').val(2);
                                }
                                form.on('switch(isHot)', function(data) {
                                    console.log('switch开关选择状态：'+this.checked);
                                    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
                                });
                            });</script>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">预告商品：</label>
                            <div class="layui-input-inline">
                                <input name="isPreview" id="isPreview" th:value="2" lay-skin="switch" lay-filter="isPreview" lay-text="是|否" type="hidden" value="2"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>否</em><i></i></div><script th:inline="javascript" type="text/javascript">layui.use(['form'], function(){
                                var form = layui.form,
                                    $ = layui.$;

                                if (2 == 1) {
                                    $("#isPreview").attr('type', 'hidden').val(1);
                                } else {
                                    $("#isPreview").attr('type', 'hidden').val(2);
                                }
                                form.on('switch(isPreview)', function(data) {
                                    console.log('switch开关选择状态：'+this.checked);
                                    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
                                });
                            });</script>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">上架状态：</label>
                            <div class="layui-input-inline">
                                <input name="status" id="status" th:value="1" lay-skin="switch" lay-filter="status" lay-text="已上架|已下架" type="hidden" checked="" value="1"><div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch"><em>已上架</em><i></i></div><script th:inline="javascript" type="text/javascript">layui.use(['form'], function(){
                                var form = layui.form,
                                    $ = layui.$;

                                if (1 == 1) {
                                    $("#status").attr('type', 'hidden').val(1);
                                } else {
                                    $("#status").attr('type', 'hidden').val(2);
                                }
                                form.on('switch(status)', function(data) {
                                    console.log('switch开关选择状态：'+this.checked);
                                    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 2);
                                });
                            });</script>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品相册：</label>
                        <div class="layui-upload-drag img_upload_image"><img id="btnUploadImg_image" src="/assets/images/default_upload.png" alt="上传相册" title="上传相册" width="90" height="90"><input class="layui-upload-file" type="file" accept="image/*" name="file" multiple=""><input type="hidden" id="image" name="image" value=""></div><style type="text/css">.layui-upload-drag {
                        position: relative;
                        padding: 10px;
                        border: 1px dashed #e2e2e2;
                        background-color: #fff;
                        text-align: center;
                        cursor: pointer;
                        color: #999;
                        margin-right:10px;
                        margin-bottom:10px;
                    }
                    .del_img{
                        position: absolute;
                        z-index: 99;
                        right: 0;
                        top: 0;
                        width: 25px;
                        height: 25px;
                        display: block;
                    }
                    .del_img img{
                        position: absolute;
                        z-index: 9;
                        right: 0px;
                        top: 0px;
                        width: 25px;
                        height: 25px;
                        display: inline-block;
                    }</style><script th:inline="javascript" type="text/javascript">layui.use(['upload','croppers'],function(){

                        //声明变量
                        var layer = layui.layer
                            ,upload = layui.upload
                            ,croppers = layui.croppers
                            ,$ = layui.$;
                        // 初始化图片隐藏域
                        var ids = '';
                        $('img[name="img_src_image"]').each(function(){
                            ids += $(this).attr('src') + ","
                        });
                        ids = ids.substr(0, (ids.length - 1));
                        $("#image").val(ids);

                        if(false==1) {
                            // 图片裁剪组件
                            croppers.render({
                                elem: '#btnUploadImg_image'
                                ,name:"image"
                                ,saveW:450     //保存宽度
                                ,saveH:450
                                ,mark:1.0    //选取比例
                                ,area:['750px','500px']  //弹窗宽度
                                ,url: "/upload/uploadImage?name=product"
                                ,done: function(url){
                                    // 如果上传失败
                                    if(!url){
                                        return layer.msg('上传失败');
                                    }

                                    var hideStr = $("#image").attr("value");
                                    var itemArr = hideStr.split(',');
                                    if(itemArr.length>="10"){
                                        layer.msg("最多上传10张图片",{ icon: 5,time: 1000}, function () {
                                            //TODO...
                                        });
                                        return false;
                                    }

                                    // 渲染界面
                                    var attStr = '<div class="layui-upload-drag">'+
                                        '<div class="del_img" onclick="remove_image_image(this);">'+
                                        '<img src="/assets/images/delete.png"></img>'+
                                        '</div>'+
                                        '<a href="'+url+'" target="_blank">'+
                                        '<img name="img_src_image" src="'+url+'" alt="相册(点击放大预览)" title="相册(点击放大预览)" width="90" height="90">'+
                                        '</a>'+
                                        '</div>';
                                    $(".img_upload_image").before(attStr);

                                    // 获取最新的图集
                                    var ids = '';
                                    $('img[name="img_src_image"]').each(function(){
                                        ids += $(this).attr('src') + ","
                                    });
                                    ids = ids.substr(0, (ids.length - 1));
                                    // 给隐藏域赋值
                                    $("#image").val(ids);

                                    return false;
                                }
                            });

                        }else{
                            /**
                             * 普通图片上传
                             */
                            var uploadInst = upload.render({
                                elem: '#btnUploadImg_image'
                                ,url: "/upload/uploadImage?name=product"
                                ,accept:'images'
                                ,acceptMime:'image/*'
                                ,exts: "jpg|png|gif|bmp|jpeg"
                                ,field:'file'//文件域字段名
                                ,size: 10*1024 //最大允许上传的文件大小
                                ,multiple: true
                                ,number: 10 //最大上传张数
                                ,before: function(obj){
                                    //预读本地文件

                                }
                                ,done: function(res){
                                    //上传完毕回调

                                    var hideStr = $("#image").attr("value");
                                    var itemArr = hideStr.split(',');
                                    if(itemArr.length>=10){
                                        layer.msg("最多上传10张图片",{ icon: 5,time: 1000}, function () {
                                            //TODO...
                                        });
                                        return false;
                                    }

                                    //如果上传失败
                                    if(res.status <= 0){
                                        return layer.msg('上传失败');
                                    }

                                    //渲染界面
                                    var attStr = '<div class="layui-upload-drag">'+
                                        '<div class="del_img" onclick="remove_image_image(this);">'+
                                        '<img src="/assets/images/delete.png"></img>'+
                                        '</div>'+
                                        '<a href="'+res.data+'" target="_blank">'+
                                        '<img name="img_src_image" src="'+res.data+'" alt="相册(点击放大预览)" title="相册(点击放大预览)" width="90" height="90">'+
                                        '</a>'+
                                        '</div>';
                                    $(".img_upload_image").before(attStr);

                                    //获取最新的图集
                                    var ids = '';
                                    $('img[name="img_src_image"]').each(function(){				ids += $(this).attr('src') + ","
                                    });
                                    ids = ids.substr(0, (ids.length - 1));
                                    //给隐藏域赋值
                                    $("#image").val(ids);

                                    return false;
                                }
                                ,error: function(){
                                    //请求异常回调
                                    return layer.msg('数据请求异常');
                                }
                            });

                        }	});

                    // 删除图片
                    function remove_image_image(obj) {
                        //obj.remove();
                        layui.$(obj).parent().remove();

                        //获取最新的图集
                        var ids = '';
                        layui.$('img[name="img_src_image"]').each(function(){
                            ids += layui.$(this).attr('src') + ","
                        });
                        ids = ids.substr(0, (ids.length - 1));
                        //给隐藏域赋值
                        layui.$("#image").val(ids);
                    }
                    </script>
                    </div>
                    <div class="layui-form-item" style="width: 625px;">
                        <label class="layui-form-label">关键词：</label>
                        <div class="layui-input-block">
                            <input name="keywords" value="" lay-verify="required" autocomplete="off" placeholder="请输入关键词" class="layui-input" type="text">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">产品服务：</label>
                        <input name="service[1]" lay-skin="primary" title="无忧退货" type="checkbox"><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>无忧退货</span><i class="layui-icon layui-icon-ok"></i></div><input name="service[2]" lay-skin="primary" title="快速退款" type="checkbox"><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>快速退款</span><i class="layui-icon layui-icon-ok"></i></div><input name="service[3]" lay-skin="primary" title="免费包邮" type="checkbox"><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>免费包邮</span><i class="layui-icon layui-icon-ok"></i></div>
                    </div>
                    <div class="layui-form-item" style="width: 625px;">
                        <label class="layui-form-label">商品备注：</label>
                        <div class="layui-input-block">
                            <textarea name="note" placeholder="请输入商品备注" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-tab layui-tab-brief" style="margin: 0px 110px !important;">
                        <ul class="layui-tab-title">
                            <li>无优惠</li>
                            <li class="layui-this">特惠促销价</li>
                            <li>会员价</li>
                            <li>阶梯价格</li>
                            <li>满减价格</li>
                        </ul>
                        <div class="layui-tab-content" style="height: 100px;width:750px">
                            <div class="layui-tab-item "></div>
                            <div class="layui-tab-item ">
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">开始时间：</label>
                                        <div class="layui-input-inline">
                                            <input name="promotionStartTime" id="promotionStartTime" value="" lay-verify="datetime" placeholder="请选择促销开始时间" autocomplete="off" class="layui-input date-icon" type="text" lay-key="2"><script th:inline="javascript" type="text/javascript">layui.use(['func'], function () {
                                            var func = layui.func;
                                            func.initDate(['promotionStartTime|datetime||'], function (value, date) {
                                                console.log("当前选择日期:" + value);
                                                console.log("日期详细信息：" + JSON.stringify(date));
                                            });});</script>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">结束时间：</label>
                                        <div class="layui-input-inline">
                                            <input name="promotionEndTime" id="promotionEndTime" value="" lay-verify="datetime" placeholder="请选择促销结束时间" autocomplete="off" class="layui-input date-icon" type="text" lay-key="1"><script th:inline="javascript" type="text/javascript">layui.use(['func'], function () {
                                            var func = layui.func;
                                            func.initDate(['promotionEndTime|datetime||'], function (value, date) {
                                                console.log("当前选择日期:" + value);
                                                console.log("日期详细信息：" + JSON.stringify(date));
                                            });});</script>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">促销价格：</label>
                                        <div class="layui-input-inline">
                                            <input name="promotionPrice" value="" lay-verify="required" autocomplete="off" placeholder="请输入促销价格" class="layui-input" type="text">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">限购数量：</label>
                                        <div class="layui-input-inline">
                                            <input name="promotionPerLimit" value="" lay-verify="required|number" autocomplete="off" placeholder="请输入活动限购数量" class="layui-input" type="text">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-tab-item "></div>
                            <div class="layui-tab-item "></div>
                            <div class="layui-tab-item "></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn layui-btn-primary" data-steps="prev"> 上一步，填写商品信息
                            </button>
                            <button class="layui-btn" lay-filter="promotionInfoSubmit" lay-submit=""> 下一步，填写商品属性 
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item layui-show">
                <form class="layui-form model-form" style="min-width: 750px;margin: 0 auto;padding: 40px 30px 0 0;">
                    <style type="text/css">.layui-upload-drag2 {
                        position: relative;
                        padding: 0px !important;
                        border: 1px dashed #e2e2e2;
                        background-color: #fff;
                        text-align: center;
                        cursor: pointer;
                        color: #999;
                        margin: 0px 0px !important;
                    }
                    </style>
                    <input name="id" id="id" type="hidden" value="0">
                    <div class="layui-form-item settingSpec">
                        <label class="layui-form-label">规格设置：</label>

                    </div>
                    <div class="layui-form-item toolSpec">
                        <label class="layui-form-label"></label>
                        <button class="layui-btn layui-btn-sm" type="button" id="addInputSpec">
                            添加新规格
                        </button>
                        <button class="layui-btn layui-btn-sm" type="button" id="generateSpec">立即生成
                        </button>
                    </div>
                    <div class="layui-form-item layui-hide inputSpec">
                        <div class="layui-inline">
                            <label class="layui-form-label">规格：</label>
                            <div class="layui-input-inline">
                                <input id="specName" name="specName" lay-verify="" autocomplete="off" placeholder="请输入规格" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">规格值：</label>
                            <div class="layui-input-inline">
                                <input id="specValue" name="specValue" lay-verify="" autocomplete="off" placeholder="请输入规格值" class="layui-input" type="text">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <button class="layui-btn layui-btn-sm" type="button" id="addSpec">添加</button>
                                <button class="layui-btn layui-btn-sm" type="button" id="cancelInputSpec">取消</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item"><label class="layui-form-label">批量设置：</label>
                        <div class="layui-input-block">
                            <table class="layui-table">
                                <thead>
                                <tr>
                                    <th style="text-align: center">图片</th>
                                    <th style="text-align: center">销售价</th>
                                    <th style="text-align: center">成本价</th>
                                    <th style="text-align: center">原价</th>
                                    <th style="text-align: center">库存</th>
                                    <th style="text-align: center">商品编码</th>
                                    <th style="text-align: center">重量(KG)</th>
                                    <th style="text-align: center">体积(m³)</th>
                                    <th style="text-align: center;" width="150px">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr>
                                    <td><div class="layui-upload-drag2"><img id="productPicId" name="productPicId" src="/assets/images/upload_mini.png" alt="上传图片" width="35" height="35"><input class="layui-upload-file" type="file" accept="image/*" name="file"><input type="hidden" id="productPic" name="productPic" value="null"></div><style type="text/css">.layui-upload-drag2 {
                                        position: relative;
                                        padding: 0px !important;
                                        border: 1px dashed #e2e2e2;
                                        background-color: #fff;
                                        text-align: center;
                                        cursor: pointer;
                                        color: #999;
                                        margin: 0px 0px !important;
                                    }</style><script th:inline="javascript" type="text/javascript">layui.use(['upload','croppers'],function(){
                                        //声明变量
                                        var layer = layui.layer
                                            ,upload = layui.upload
                                            ,croppers = layui.croppers
                                            ,$ = layui.$;

                                        if(false) {

                                            //图片裁剪组件
                                            croppers.render({
                                                elem: '#productPicId'
                                                ,name:"productPic"
                                                ,saveW:450     //保存宽度
                                                ,saveH:300
                                                ,mark:1/1    //选取比例
                                                ,area:['750px','500px']  //弹窗宽度
                                                ,url: "/upload/uploadImage?name=product"
                                                ,done: function(url){
                                                    //上传完毕回调
                                                    $('#productPic').val(url);
                                                    $('#productPicId').attr('src',url);
                                                }
                                            });

                                        }else{

                                            /**
                                             * 普通图片上传
                                             */
                                            var uploadInst = upload.render({
                                                elem: '#productPicId'
                                                ,url: "/upload/uploadImage?name=product"
                                                ,accept:'images'
                                                ,acceptMime:'image/*'
                                                ,exts: "jpg|png|gif|bmp|jpeg"
                                                ,field:'file'//文件域字段名
                                                ,size: 1024 * 10 //最大允许上传的文件大小
                                                ,before: function(obj){
                                                    //预读本地文件
                                                }
                                                ,done: function(res){
                                                    //上传完毕回调

                                                    if(res.code!=0){
                                                        layer.msg(res.msg,{ icon: 5 });
                                                        return false;
                                                    }

                                                    //上传成功
                                                    $('#productPicId').attr('src', res.data);
                                                    $('#productPic').val(res.data);
                                                }
                                                ,error: function(){
                                                    //请求异常回调
                                                    return layer.msg('数据请求异常');
                                                }
                                            });

                                        }

                                    });</script></td>
                                    <td><input type="text" class="layui-input" id="price"></td>
                                    <td><input type="text" class="layui-input" id="costPrice"></td>
                                    <td><input type="text" class="layui-input" id="originalPrice"></td>
                                    <td><input type="text" class="layui-input" id="stock"></td>
                                    <td><input type="text" class="layui-input" id="skuCode"></td>
                                    <td><input type="text" class="layui-input" id="volume"></td>
                                    <td><input type="text" class="layui-input" id="weight"></td>
                                    <td style="text-align: center;">
                                        <button type="button" class="layui-btn layui-btn-sm" id="batchSku">批量修改</button>
                                        <button type="button" class="layui-btn layui-btn-sm layui-btn-danger" id="clearSku">清空</button>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-block">
                            <table id="skuTable" class="layui-table">
                                <thead>

                                <tr>

                                </tr>
                                </thead>
                                <tbody>

                                </tbody>
                            </table>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn layui-btn-primary" data-steps="prev"> 上一步，填写商品促销
                                </button>
                                <button class="layui-btn" lay-filter="skuInfoSubmit" lay-submit=""> 保存并提交 
                                </button>
                            </div>
                        </div>
                    </div>
                    <script>
                        layui.use(['jquery', 'form', 'func'], function () {
                            var $ = layui.jquery;
                            var form = layui.form;
                            var func = layui.func;

                            // 添加新规格
                            $("#addInputSpec").click(function () {
                                $(".toolSpec").addClass("layui-hide");
                                $(".inputSpec").removeClass("layui-hide");
                            });

                            // 取消规格
                            $("#cancelInputSpec").click(function () {
                                $(".toolSpec").removeClass("layui-hide");
                                $(".inputSpec").addClass("layui-hide");
                            });

                            // 添加规格
                            $("#addSpec").click(function () {
                                // 规格名称
                                var specName = $("#specName").val();
                                if (specName == "") {
                                    layer.msg("规格名称不能为空", {icon: 5});
                                    return false;
                                }
                                // 规格属性
                                var specValue= $("#specValue").val();
                                if (specValue == "") {
                                    layer.msg("规格属性不能为空", {icon: 5});
                                    return false;
                                }
                                var item = [];
                                $('input[id^=specTag_]').each(function(index, element){
                                    var id = $(this).attr("id");
                                    var value = parseInt(id.replace(/[^0-9]/ig,""))
                                    item.push(value);
                                });
                                var maxValue = 0;
                                if (item.length > 0) {
                                    maxValue = Math.max.apply(null, item);
                                }
                                var html = "<ul class=\"layui-input-block\" style=\"margin-top: 10px;\">\n" +
                                    "\t\t\t\t\t\t\t<li>\n" +
                                    "\t\t\t\t\t\t\t\t<button type=\"button\" class=\"layui-btn layui-btn-sm layui-btn-normal\" data-name=\"" + specName + "\">" + specName + "<i class=\"layui-icon\">&#xe640;</i></button>\n" +
                                    "\t\t\t\t\t\t\t\t<ul>\n" +
                                    "\t\t\t\t\t\t\t\t\t<input id=\"specTag_" + (maxValue + 1) + "\" value=\""+ specValue +"\" class=\"layui-hide\"/>\n" +
                                    "\t\t\t\t\t\t\t\t\t<script>\n" +
                                    "\t\t\t\t\t\t\t\t\t\tlayui.use(['jquery', 'tagsInput'], function () {\n" +
                                    "\t\t\t\t\t\t\t\t\t\t\tvar $ = layui.jquery;\n" +
                                    "\t\t\t\t\t\t\t\t\t\t\tvar tagsInput = layui.tagsInput;\n" +
                                    "\t\t\t\t\t\t\t\t\t\t\t// 无边框样式\n" +
                                    "\t\t\t\t\t\t\t\t\t\t\t$('#specTag_" + (maxValue + 1) + "').tagsInput({skin: 'tagsinput-default'});\n" +
                                    "\t\t\t\t\t\t\t\t\t\t});\n" +
                                    "\t\t\t\t\t\t\t\t\t<\/script>\n"+
                                    "\t\t\t\t\t\t\t\t</ul>\n"+
                                    "\t\t\t\t\t\t\t</li>\n"+
                                    "\t\t\t\t\t\t</ul>";
                                // 尾部插入HTML
                                $(".settingSpec").append(html);
                                // 初始化控件
                                $("#specName").val("");
                                $("#specValue").val("");

                                // 关闭输入面板
                                $(".toolSpec").removeClass("layui-hide");
                                $(".inputSpec").addClass("layui-hide");
                            });

                            // 批量设置SKU
                            $("#batchSku").click(function () {
                                // 图片
                                var productPic = $("#productPicId")[0].src;
                                $("img[name^='coverImg_']").each((i,val)=>{
                                    $(val).attr('src', productPic);
                                });
                                // 图片隐藏域赋值
                                $("input[name^='coverImg']").each((i,val)=>{
                                    $(val).val(productPic);
                                });
                                // 销售价
                                var price = $("#price").val();
                                $("input[name='price']").each((i,val)=>{
                                    $(val).val(price);
                                });
                                // 成本价
                                var costPrice = $("#costPrice").val();
                                $("input[name='costPrice']").each((i,val)=>{
                                    $(val).val(costPrice);
                                });
                                // 原价
                                var originalPrice = $("#originalPrice").val();
                                $("input[name='originalPrice']").each((i,val)=>{
                                    $(val).val(originalPrice);
                                });
                                // 库存
                                var stock = $("#stock").val();
                                $("input[name='stock']").each((i,val)=>{
                                    $(val).val(stock);
                                });
                                // 商品编码
                                var skuCode = $("#skuCode").val();
                                $("input[name='skuCode']").each((i,val)=>{
                                    $(val).val(skuCode);
                                });
                                // 体积
                                var volume = $("#volume").val();
                                $("input[name='volume']").each((i,val)=>{
                                    $(val).val(volume);
                                });
                                // 重量
                                var weight = $("#weight").val();
                                $("input[name='weight']").each((i,val)=>{
                                    $(val).val(weight);
                                });
                            });

                            // 情况当前所有input框的值
                            $("#clearSku").click(function () {
                                $(this).parent().parent().find("input").each((i,val)=>{
                                    $(val).val("");
                                });
                            });

                            // 商品ID
                            var productId = $("#id").val();

                            // 生成SKU
                            $("#generateSpec").click(function () {

                                layer.confirm('立即生成将导致SKU信息重新生成，确定要重新生成吗？', {
                                    icon: 3,
                                    skin: 'layer-ext-moon',
                                    btn: ['确认', '取消'] //按钮
                                }, function (index) {
                                    // 关闭弹窗
                                    layer.close(index);

                                    $('#skuTable thead tr').html('');
                                    $('#skuTable tbody').html('');
                                    //循环所有的行，判断选中的
                                    var allSKU='';
                                    var guiArray=[];
                                    var stArray=[];
                                    $('.settingSpec ul li').each((i,val)=>{
                                        var title = $(val).children("button").data("name");
                                        var value = $(val).find("input[id^='specTag']").val();

                                        var array = value.split(",");
                                        stArray.push(title)

                                        stArray=Array.from(new Set(stArray))
                                        guiArray.push(array);
                                        guiArray=guiArray.filter(function(current){
                                            return current.length>0
                                        });
                                    });

                                    //循环stArray拼表头
                                    //循环allSKU拼tbody
                                    var strhead=''
                                    $.each(stArray,(i,val)=>{
                                        strhead+=`<th width="100px" style="text-align:center">${val}</th>`;
                                    });
                                    strhead+=`<th style="text-align:center">图片</th>
												<th style="text-align:center">销售价</th>
												<th style="text-align:center">成本价</th>
												<th style="text-align:center">原价</th>
												<th style="text-align:center">库存</th>
												<th style="text-align:center">商品编码</th>
												<th style="text-align:center">重量(KG)</th>
												<th style="text-align:center">体积(m³)</th>
												<th style="text-align:center">是否启用</th>
												<th style="text-align: center;" width="90px">操作</th>`;
                                    $('#skuTable thead tr').append(strhead);

                                    var skuList = [];

                                    //所有的sku组合
                                    allSKU=calcDescartes(guiArray);
                                    $.each(allSKU,(i,obj)=>{
                                        var td=``;
                                        var titleArr = [];
                                        if(obj instanceof Array){
                                            $.each(obj,(i,val)=>{
                                                td+=`<td style="text-align:center">${val}</td>`;
                                                titleArr.push(val);
                                            });
                                        }else{
                                            td+=`<td style="text-align:center">${obj}</td>`
                                        }
                                        // 字符换拼接
                                        var tr = '<tr data-name="'+titleArr.join(",")+'">' + td;
                                        tr+='<td style="text-align:center;">'+
                                            '<div class="layui-upload-drag2">'+
                                            '<img id="coverImg_'+i+'" name="coverImg_'+i+'" src="/assets/images/upload_mini.png" alt="上传图片" width="35" height="35">'+
                                            '<input class="layui-upload-file" type="file" accept="image/*" name="file">'+
                                            '</div>'+
                                            '<script type="text/javascript">'+
                                            '\t\tlayui.use(["upload","croppers"],function(){'+
                                            '\t\t\tvar layer = layui.layer'+
                                            '\t\t\t\t\t,upload = layui.upload'+
                                            '\t\t\t\t\t,croppers = layui.croppers'+
                                            '\t\t\t\t\t,$ = layui.$;'+
                                            '\t\t\tvar uploadInst = upload.render({'+
                                            '\t\t\t\telem: "#coverImg_'+i+'"'+
                                            '\t\t\t\t,url: "/upload/uploadImage?name=product"'+
                                            '\t\t\t\t,accept:"images"'+
                                            '\t\t\t\t,acceptMime:"image/*"'+
                                            '\t\t\t\t,exts: "jpg|png|gif|bmp|jpeg"'+
                                            '\t\t\t\t,field:"file"'+
                                            '\t\t\t\t,size: 1024 * 10'+
                                            '\t\t\t\t,before: function(obj){'+
                                            '\t\t\t\t}'+
                                            '\t\t\t\t,done: function(res){'+
                                            '\t\t\t\t\tif(res.code!=0){'+
                                            '\t\t\t\t\t\tlayer.msg(res.msg,{ icon: 5 });'+
                                            '\t\t\t\t\t\treturn false;'+
                                            '\t\t\t\t\t}'+
                                            '\t\t\t\t\t$("#coverImg_'+i+'").attr("src", res.data);'+
                                            '\t\t\t\t}'+
                                            '\t\t\t\t,error: function(){'+
                                            '\t\t\t\t\treturn layer.msg("数据请求异常");'+
                                            '\t\t\t\t}'+
                                            '\t\t\t});'+
                                            '\t\t});'+
                                            '<\/script>'+
                                            '</td>'+
                                            '<td style="text-align:center"><input name="price" class="layui-input" placeholder="请输入销售价"></td>'+
                                            '<td style="text-align:center"><input name="costPrice" class="layui-input" placeholder="请输入成本价"></td>'+
                                            '<td style="text-align:center"><input name="originalPrice" class="layui-input" placeholder="请输入原价"></td>'+
                                            '<td style="text-align:center"><input name="stock" class="layui-input" placeholder="请输入库存"></td>'+
                                            '<td style="text-align:center"><input name="skuCode" class="layui-input" placeholder="请输入商品编码"></td>'+
                                            '<td style="text-align:center"><input name="volume" class="layui-input" placeholder="请输入体积(m³)"></td>'+
                                            '<td style="text-align:center"><input name="weight" class="layui-input" placeholder="请输入重量(KG)"></td>'+
                                            '<td style="text-align:center"><input type="checkbox" name="status[]" lay-skin="primary" checked="" title="是否启用"></td>'+
                                            '<td style="text-align: center;">'+
                                            '<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" onclick="deleteSku(this);">删除</button>'+
                                            '</td>';
                                        $('#skuTable tbody').append(tr);

                                        var item = {
                                            attributeValue:titleArr.join(","),
                                            productPic: '',
                                            price:0,
                                            costPrice:0,
                                            originalPrice:0,
                                            stock:0,
                                            skuCode:'',
                                            volume:0,
                                            weight:0,
                                        };
                                        skuList.push(item);
                                    });

                                    // 生成SKU
                                    func.ajaxPost("/product/generateSku", {"productId":productId,"skuList":skuList,"specs":stArray,"attrs":guiArray}, function (res, success) {
                                        if (success) {
                                            // 延迟0.5秒
                                            setTimeout(function () {
                                                // // 关闭窗体
                                                // layer.closeAll("iframe");
                                                // 刷新父页面
                                                // location.reload();
                                            }, 500);
                                        }
                                    }, "SKU生成中,请耐心等待。。。");
                                    return false;
                                });
                            });


                            /* 表单一提交事件 */
                            form.on('submit(skuInfoSubmit)', function (data) {
                                //循环所有的行，判断选中的
                                var guiArray=[];
                                var stArray=[];
                                $('.settingSpec ul li').each((i,val)=>{
                                    var title = $(val).children("button").data("name");
                                    var value = $(val).find("input[id^='specTag']").val();

                                    var array = value.split(",");
                                    stArray.push(title)

                                    stArray=Array.from(new Set(stArray))
                                    guiArray.push(array);
                                    guiArray=guiArray.filter(function(current){
                                        return current.length>0
                                    });
                                });

                                var skuList = [];
                                $("#skuTable tbody tr").each((i,obj)=>{
                                    // 封面
                                    var productPic = $(obj).find("img[name^='coverImg_']")[0].src;
                                    // 销售价
                                    var price = $(obj).find("input[name='price']").val();
                                    // 成本价
                                    var costPrice = $(obj).find("input[name='costPrice']").val();
                                    // 原价
                                    var originalPrice = $(obj).find("input[name='originalPrice']").val();
                                    // 库存
                                    var stock = $(obj).find("input[name='stock']").val();
                                    // SKU编码
                                    var skuCode = $(obj).find("input[name='skuCode']").val();
                                    // 体积
                                    var volume = $(obj).find("input[name='volume']").val();
                                    // 重量
                                    var weight = $(obj).find("input[name='weight']").val();
                                    // 启用状态
                                    var status = $(obj).find("input[type=checkbox]").prop("checked") == true ? 1 : 2;

                                    var item = {
                                        productPic: productPic,
                                        price:price,
                                        costPrice:costPrice,
                                        originalPrice:originalPrice,
                                        stock:stock,
                                        skuCode:skuCode,
                                        volume:volume,
                                        weight:weight,
                                        attributeValue:$(obj).data("name"),
                                        status:status,
                                    };
                                    skuList.push(item);
                                });

                                // 保存SKU数据
                                func.ajaxPost("/product/updateSku", {"productId":productId,"skuList":skuList}, function (res, success) {
                                    if (success) {
                                        // 延迟0.5秒
                                        setTimeout(function () {
                                            layer.confirm('您确定要返回商品列表页吗？', {
                                                icon: 3,
                                                skin: 'layer-ext-moon',
                                                btn: ['确认', '取消'] //按钮
                                            }, function (index) {
                                                // 关闭弹窗
                                                layer.close(index);
                                                // 关闭窗体
                                                layer.closeAll("iframe");
                                                // 刷新父页面
                                                parent.location.reload();
                                            });

                                        }, 1000);
                                    }
                                }, "数据处理中,请耐心等待。。。");
                                return false;
                            });

                        });

                        //商品组合
                        function calcDescartes (array) {
                            if (array.length < 2) return array[0] || [];
                            return [].reduce.call(array, function (col, set) {
                                var res = [];
                                col.forEach(function (c) {
                                    set.forEach(function (s) {
                                        var t = [].concat(Array.isArray(c) ? c : [c]);
                                        t.push(s);
                                        res.push(t);
                                    })
                                });
                                return res;
                            });
                        }

                        // 移除当前标签
                        function removeTag(obj) {
                            layui.$(obj).parent().parent().remove();
                        }

                        // 删除SKU
                        function deleteSku(obj) {
                            // 商品ID
                            var productId = layui.$("#id").val();
                            // SKU参数
                            var attributeValue = layui.$(obj).parent().parent().data("name");
                            // 删除SKU
                            layui.func.ajaxPost("/product/deleteSku", {"productId":productId,"attributeValue":attributeValue}, function (res, success) {
                                if (success) {
                                    layui.$(obj).parent().parent().remove();
                                }
                            }, "数据处理中,请耐心等待。。。");
                            return false;
                        }

                    </script>
                </form>
            </div>
        </div>
    </div>
    <script>
        layui.use(['layer', 'form', 'steps', 'common'], function () {
            var $ = layui.jquery;
            var form = layui.form;
            var steps = layui.steps;
            var common = layui.common;

            // 提交商品信息
            form.on('submit(productInfoSubmit)', function (data) {
                // 提交表单
                common.submitForm(data.field, "/product/add", function (res, success) {
                    if (success) {
                        $("input[name='id']").val(res.data);
                        steps.next('formStepsStep');
                    }
                }, false);
                return false;
            });

            // 提交促销信息
            form.on('submit(promotionInfoSubmit)', function (data) {
                // 提交表单
                common.submitForm(data.field, "/product/update", function (res, success) {
                    if (success) {
                        steps.next('formStepsStep');
                    }
                }, false);
                return false;
            });
        });
    </script>
</div>
</html>